import { createContext, useContext } from "react";

export const DBContext = createContext<IDBDatabase>({} as IDBDatabase);

export const useDB = () => {
  const db = useContext(DBContext);
  return db;
};

export interface AppState {
  chatId: string;
  setChatId: (chatId: string) => void;
  msgList: any[];
  setMsgList: React.Dispatch<React.SetStateAction<any[]>>;
  sendMsg: (text: string) => void;
}
export const StateContext = createContext({} as AppState);

export const useAppState = () => {
  const state = useContext(StateContext);

  return state;
};
